package symbol;

import java.util.List;

public class ArraySymbol extends Symbol {
    private final int size; // 数组大小
    private final SymbolKind kind;
    boolean canCaclulate = false; // 是否可以计算
    // type: 数组类型(存储在Symbol中)

    // 我们可以知道，数组的长度是确定可计算的
    List<Integer> valueList;
    String valueString;

    public ArraySymbol(String name, SymbolType type, int size, SymbolKind kind, int scopeLevel, int scopeNumber) {
        super(name, type, scopeLevel, scopeNumber);
        this.size = size;
        this.kind = kind;
    }

    public ArraySymbol(String name, SymbolType type, int size, SymbolKind kind, int scopeLevel, int scopeNumber,
            List<Integer> valueList) {
        super(name, type, scopeLevel, scopeNumber);
        this.size = size;
        this.kind = kind;
        this.valueList = valueList;
        if (kind == SymbolKind.CONSTANT) {
            canCaclulate = true;
        }
    }

    public SymbolKind getKind() {
        return kind;
    }

    public boolean canCaclulate() {
        return canCaclulate;
    }

    public String getTypeName() {
        if (kind == SymbolKind.CONSTANT && getType() == SymbolType.INT) {
            return "ConstIntArray";
        } else if (kind == SymbolKind.CONSTANT && getType() == SymbolType.CHAR) {
            return "ConstCharArray";
        } else if (kind == SymbolKind.VARIABLE && getType() == SymbolType.INT) {
            return "IntArray";
        } else if (kind == SymbolKind.VARIABLE && getType() == SymbolType.CHAR) {
            return "CharArray";
        } else {
            return "UnknownArray";
        }
    }

    public int getSize() {
        return size;
    }
}
